{{extend './layout.htm'}}

{{block 'main'}}
<form method="post" action="{{url('save')}}" class="layui-form">
    <input type="hidden" name="id" value="{{link.id}}">
    <div class="layui-tab-item layui-show">
        <div class="layui-form-item">
            <label class="layui-form-label">链接分类</label>
            <div class="layui-input-block">
                <select name="pid" lay-verify="required">
                    <option value="0">顶级分类</option>
                    {{each link_list item}}
                    <option value="{{item.id}}" {{(item.id == link.pid || item.id == pid) && 'selected'}}><%for (var i=1;i<item.level;i++) {%>&nbsp;&nbsp;&nbsp;&nbsp;<%}%>├─{{item.title}}</option>{{/each}}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">链接图标</label>
            <div class="layui-input-block">
                <input type="text" name="icon" class="layui-input" value="{{link.icon}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">链接文字</label>
            <div class="layui-input-block">
                <input type="text" name="title" class="layui-input" value="{{link.title}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">链接地址</label>
            <div class="layui-input-block">
                <input type="text" name="url" class="layui-input" value="{{link.url}}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">链接排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" class="layui-input" value="{{link.sort || 0}}">
            </div>
        </div>
    </div>

    <div style="text-align: center;">
        <button class="layui-btn" lay-submit>提交</button>
    </div>
</form>
{{/block}}

{{block 'js'}}
<script>
    layui.use(['form', 'element'], function(){
        var form = layui.form;
        var element = layui.element;
    });
</script>
{{/block}}